package com.payment.service.impl;


import com.payment.mapper.SequenceMapper;
import com.payment.service.SequenceService;
import com.payment.utils.sequence.DateUtils;
import com.payment.utils.sequence.SequenceHepler;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.Date;

@Transactional
@Service
public class SequenceServiceImpl implements SequenceService {
    @Resource
    SequenceMapper sequenceMapper;
    private String PACKAGES_SEQ = "seq_getPackages_connseqno";
    private String ORDERS_SEQ = "seq_orders_connseqno";
    private String PAYNOTIFY_SEQ = "seq_paynotify_connseqno";
    private String QUERYORDER_SEQ = "seq_queryorder_connseqno";
    private String CHANNELORDERID_SEQ = "seq_channelorderId_connseqno";
    private String TEMORDERID_SEQ = "seq_temOrderId_connseqno";
    private String USERID_SEQ="seq_userId_connseqno";

    @Override
    public String getPackageTaskNo() {
        String timeFix = DateUtils.format(new Date(), "yyyyMMdd");
        return SequenceHepler.generateSequence(
                /** 前缀 */
                String.format("%s%s", "F0001", timeFix),
                /** 当前序号值 */
                sequenceMapper.findCurrentVal(PACKAGES_SEQ),
                /** 数值长度 */
                10);
    }


}
